//
//  StoreDetailButton.m
//  much
//
//  Created by weijunjie on 2019/1/8.
//  Copyright © 2019年 iOS. All rights reserved.
//

#import "StoreDetailButton.h"
@interface StoreDetailButton()
@property (nonatomic, weak) UILabel *nameLabel;

@end
@implementation StoreDetailButton

- (instancetype)initWithIconStr:(NSString *)iconStr
                          title:(NSString *)title
{
    self = [super init];
    if (self) {
        UILabel *iconLabel = [[UILabel alloc] init];
        _iconLabel = iconLabel;
        iconLabel.text = iconStr;
        iconLabel.font = ICONFONT(18);
        if ([title isEqualToString:@"收藏"]) {
            iconLabel.font = ICONFONT(16);
        }
        iconLabel.textColor= Color80;
        [self addSubview:iconLabel];
        [iconLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            if ([title isEqualToString:@"收藏"]) {
                make.top.equalTo(self).offset(7);
            } else {
                make.top.equalTo(self).offset(6);
            }
            make.centerX.equalTo(self);
        }];
        UILabel *nameLabel = [[UILabel alloc] init];
        _nameLabel = nameLabel;
        nameLabel.text = title;
        nameLabel.textColor = Color80;
        nameLabel.font = APPFONT(10);
        [self addSubview:nameLabel];
        [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(32);
            make.centerX.equalTo(iconLabel);
        }];
    }
    return self;
}

- (void)setTitle:(NSString *)title forState:(UIControlState)state {
    
}

- (void)setSelected:(BOOL)selected {
    if ([self.nameLabel.text isEqualToString:@"收藏"]) {
        if (selected) {
            self.iconLabel.text = @"\uE65f";
            self.iconLabel.textColor= Color175030;
        } else {
            self.iconLabel.text = @"\uE664";
            self.iconLabel.textColor= Color80;
        }
    }
}

@end
